Skip to content

fix(bgp): let Metro's drawables win over an embedded library's copy - #521

Merged
hurali97 merged 2 commits into
callstack:mainfrom
KisaneNeko:fix/bgp-metro-res-duplicates
Nov 9, 2026
Merged

hurali97 merged 2 commits into
callstack:mainfrom
KisaneNeko:fix/bgp-metro-res-duplicates

Conversation

@KisaneNeko

Copy link
Copy Markdown
Contributor

Problem

Some libraries commit the drawables Metro generates for their JS assets (node_modules_<lib>_assets_*) to their own res/. The app's bundle writes the same files to generated/res/react, and both end up as generated res of the brownfield module, so packaging fails with Duplicate resources. Nothing ordered copyExplodedResFor<Variant> after the bundle task either, and its cache key didn't include Metro's output.

Change

  • ResourceTaskProcessor.kt: CopyExplodedResTask reads the createBundle<Variant>JsAndAssets task's resourcesDir as one of the module's own res dirs, so the merger from fix(bgp): merge res/values of embedded libraries instead of overwriting #513 drops a library's copy and Metro's wins. Reading the task's output also orders the copy after the bundle and adds Metro's files to the cache key, so @CacheableTask stays.
  • VariantHelper.getMetroBundleTaskName and utils/TaskOutputs.kt: the bundle task name and the task-output lookup moved out of RNSourceSets.kt, which now uses the same helpers.

Reproduced with RNApp by copying one of its Metro drawables into an embedded library's res/: main fails in packageDevDebugResources with the duplicate, this branch builds and the AAR has one copy per density, byte-identical to Metro's.

Before merging

Build the host app against an AAR with a colliding drawable and check the image renders.

Some libraries commit the drawables Metro generates for their JS assets
to their own res, and the app's bundle writes the same files to
generated/res/react. Both ended up as generated res of the brownfield
module, so packaging failed with duplicate resources. Treat Metro's
output as the module's own in the resource copy task, which also orders
the copy after the bundle and keys its cache on it.
@KisaneNeko
KisaneNeko marked this pull request as ready for review November 5, 2026 17:44

@andrei-zgirvaci andrei-zgirvaci left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! This fixes our blocker. Thank you!

@hurali97
hurali97 merged commit 58aedad into callstack:main Nov 9, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants